<link href="../../../css/common.css" rel="stylesheet" type="text/css" />
<style>
    input, select {
        height: 26px;
    }

    .button-control {
        height: 50px;
    }

    .button-control a {
        display: inline-block;
        float: left;
        margin: 2px 0 0 5px;
        width: 70px;
    }

    .btn-rep {
        border: 1px solid #ccc;
        border-radius: 4px;
        background: #DFDFDF;
    }

    .btn-rep:hover, .rep-selected {
        background: #428BCA;
        color: #fff;
    }

    .select-person {
        width: 150px;
        height: 32px;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        color: #555;
        background-color: #fff;
        background-image: none;
        border: 1px solid #ccc;
        border-radius: 4px;
        -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
        -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
        -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        vertical-align: middle;
    }
</style>
<div class="form-group">

    <form action="">
        <label class="control-label" for="textinput">小区:</label>
        <!--<select ng-model="communityId" ng-options="m.objId as m.communityName for m in communityLabelList.data"-->
                <!--ng-change="getActivityList(communityId,level,description)">-->
            <!--<option value="">&#45;&#45; 请选择 &#45;&#45;</option>-->
        <!--</select>-->
        <input type = "text" id = "community_select" ng-model="communityId" value = "">

        <label class="control-label" for="textinput">精华帖:</label>
        <select ng-model="level"
                ng-change="getActivityList(communityId,level,description)">
            <option value="3">全部</option>
            <option value="1">精华帖</option>
            <option value="0">非精华帖</option>
        </select>
        <span style="font-weight:bold">&nbsp;&nbsp;&nbsp;关键字 &nbsp;<input type="text" ng-model="description"
                                                                          placeholder=""></span>
        <button style="margin-left: 20px;" type="submit" class="btn-secondary btn-sm" ng-click="getActivityList(communityId, level, description)">搜索</button>
        <button style="margin-left: 20px;" type="submit" class="btn-secondary btn-sm" ng-click="exportJoinActivityExcel()">导出</button>

        <br>
    </form>
</div>
<div class="tabbable" id="tabs-932122" style="margin-top: 40px">
    <div class="tab-content">
        <mutau>
            <ul class="pagination" num-pages="tasks.pageCount" current-page="tasks.currentPage"
                on-select-page="selectPage(page)">
                <li ng-class="{disabled: noPrevious()}"><a ng-click="selectPrevious()">&laquo;</a>

                </li>
                <li ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a
                        ng-click="selectPage(page)">{{page}}</a>

                </li>
                <li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">&raquo;</a>

                </li>
                <li ng-show="currentPage>6"><a ng-click="selectPage(1)">首页</a>

                </li>
            </ul>
        </mutau>

        <table class="table table-condensed">
            <thead>
            <tr>
                <th>小区</th>
                <th>板块内小区</th>
                <th>标签</th>
                <th>昵称</th>
                <th>标题</th>
                <th>描述</th>
                <th>创建时间</th>
                <th>结束时间</th>
                <th width = "80">浏览量数</th>
                <th width = "70">回复数</th>
                <th width = "80">参加人数</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="activity in activityList">

                <td style="width: 80px;">{{activity.community.communityName}}</td>
                <td style="width: 90px;"><span ng-repeat="t in activity.aroundCommunity">{{arCommunity[t]}} </span></td>
                <td style="width: 60px;"><span ng-repeat="t in activity.tag">{{t.value}} </span></td>
                <td>{{activity.createdBy.nickName}}</td>
                <td>{{activity.title}}</td>
                <td><div style = "width: 300px;word-wrap: break-word;">{{activity.desc}}</div></td>
                <td>{{activity.dateCreated | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                <td>{{activity.deadline | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                <td>{{activity.browserCount}}</td>
                <td>{{activity.replies.length}}<br/><a data-toggle="modal" data-target="#replies{{$index}}" ng-click="">查看</a></td><!-- DO A COUNT ON THE NUMBER OF REPLIES -->
                <td>{{activity.partakeNum}}</td>
                <td><a class="btn btn-default btn-xs" data-toggle="modal" data-target="#edit{{$index}}"
                       ng-click="initTag()">编辑</a>
                    <a class="btn btn-primary btn-xs" ng-show="activity.displayOrder!=3"
                       ng-click="moveToTop(activity.objId,communityId)">置顶</a>
                    <a class="btn btn-danger btn-xs" ng-show="activity.displayOrder==3"
                       ng-click="cancelTop(activity.objId,communityId)">取消</a>

                    <a ng-show="activity.level!=1" class="btn btn-secondary btn-xs"
                       ng-click="changeLevel(activity,1)">设置精华贴</a>
                    <a ng-show="activity.level==1" class="btn btn-danger btn-xs"
                       ng-click="changeLevel(activity,0)">取消精华帖</a>

                    <a class="btn btn-primary btn-xs" ng-show="activity.isFresh !=true" data-toggle="modal"
                       data-target="#fresh{{$index}}"
                       ng-click="">添加新鲜事</a>

                    <a class="btn btn-secondary btn-xs" data-toggle="modal" data-target="#members{{$index}}"
                       ng-click="">参加人员</a>


                    <div class="modal fade" id="fresh{{$index}}" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel" aria-hidden="false">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-label="Close"><span
                                            aria-hidden="true">&times;</span></button>
                                    <h5 class="modal-title" id="myFresh">活动：{{activity.desc}}</h5>
                                </div>
                                <div class="modal-body">
                                    <h6 class="modal-title" id="myFresh1">请输入标题：</h6>
                                        <textarea rows="5" ng-model="title" required style="width:100%"
                                                  tabindex="7"></textarea>
                                </div>
                                <div class="modal-footer">
                                    <button ng-click="addActivityToFreshNews(activity,title)" type="button"
                                            class="btn btn-default btn-sm" data-dismiss="modal">确定
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <a ng-show="activity.isFresh == true">已在新鲜事</a>

                    <div class="modal fade" id="edit{{$index}}" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel" aria-hidden="false">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-label="Close"><span
                                            aria-hidden="true">&times;</span></button>
                                    <h5 class="modal-title" id="refusal">标题：{{activity.title}}</h5>
                                </div>
                                <div class="modal-body">
                                    <div>
                                        <p style="text-align: center">Edit Neighbourhood Activity</p>
                                        <p class="text-danger" ng-show="showErrorMsg">{{onErrorMsg}}</p>
                                        标题:<input type="text"  ng-model="activity.title" style="width: 80%;"/> <br><br/>
                                        内容:<input type="text"  ng-model="activity.desc" style='width:80%'/> <br><br/>
                                        <!--结束时间:<input type="text" id="endDate" data-provide="datepicker" class="form-control datepicker" data-date-format="yyyy-MM-dd HH:mm:ss" ng-model="activity.deadline" style="width: 80%;">-->
                                        <div class="form-group">
                                            <label class="control-label" for="textinput">图片：<!--category:--></label>
                                            <!--<img ng-src={{qimages.url}} id="imgs"  />-->
                                            <!--<img class="form-control" ng-model="question.data.images" id="imgs">-->
                                            <slide ng-repeat="img in activity.images" active="img.active">
                                                <img ng-src="http://{{imgHost+img.imageURL}}" style="width: 100px;" onclick="if($(this).width()==100){
                                                $('img').width(100);
                                                $(this).width(360);
                                                }else{
                                                $(this).width(100);
                                                };">
                                            </slide>
                                        </div>

                                        标签 <br/>
                                        <label ng-repeat="m in tag.data">
                                            <input style="zoom:1.5;margin-left: 10px;vertical-align:middle"
                                                   type="checkbox" ng-model="chk" ng-click="toggle(chk,m.objId)"/>{{m.value}}
                                        </label>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button
                                            class="btn btn-default btn-sm" data-dismiss="modal">取消
                                    </button>
                                    <button ng-click="updateActivity(activity)"
                                            type="submit"
                                            class="btn btn-default btn-sm" data-dismiss="modal">确定
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal fade" id="members{{$index}}" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel" aria-hidden="false">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-label="Close"><span
                                            aria-hidden="true">&times;</span></button>
                                    <p style="text-align: center">参加人员</p>
                                    <h5 class="modal-title">标题：{{activity.title}}</h5>
                                </div>
                                <div class="modal-body">
                                    <table class="table table-condensed">
                                        <thead>
                                        <tr>
                                            <th>姓名</th>
                                            <th>用户类型</th>
                                            <th>数量</th>
                                            <th>备注</th>
                                            <th>电话</th>
                                            <th>收货地址</th>
                                            <th>参加时间</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr ng-repeat="member in activity.partake">
                                            <td>{{member.name + member.user.nickName}}</td>
                                            <td>{{member.partakeType=="1"?"APP用户":"微信用户"}}</td>
                                            <td>{{member.number}}</td>
                                            <td>{{member.note}}</td>
                                            <td>{{member.phone}}</td>
                                            <td>{{member.address}}</td>
                                            <td>{{member.time | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="modal-footer">
                                    <button
                                            class="btn btn-default btn-sm" data-dismiss="modal">取消
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal fade" id="replies{{$index}}" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content" style = "overflow-y: scroll;height: 600px;">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-label="Close"><span
                                            aria-hidden="true">&times;</span></button>
                                    <p style="text-align: center">回复</p>
                                    <h5 class="modal-title">标题：{{activity.title}}</h5>
                                </div>
                                <div class="modal-body">
                                    <slide ng-repeat="img in activity.replies.images" active="img.active">
                                        <img ng-src="http://t.img.66xiaoqu.com{{img.imageURL}}" style="width: 180px;height: 180px;">
                                    </slide>
                                </div>
                                <div class="modal-body">
                                    <table class="table table-condensed">
                                        <thead>
                                        <tr>
                                            <th>回复内容</th>
                                            <th>回复者</th>
                                            <th>回复时间</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr ng-repeat="r in activity.replies"  data-rep-id={{r.repliedBy.objId}} data-rep-name={{r.repliedBy.nickName}} ng-click="getRepId($event)">
                                            <td width="200" style = "white-space:normal;">{{r.replyDesc}}</td>
                                            <td width="100">{{r.repliedBy.nickName}}</td>
                                            <td width="150">{{r.dateReplied | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                    <form>
                                    <div style = "margin-bottom: 10px;">
                                        <label style = "margin-right: 42px;" ng-click="repPost($event)"><input type="radio" checked="true" name="repClass" value="post" class="rep-post radio-rep"> 回复帖子</label>
                                        <label style = "margin-right: 6px;" ng-click="repPerson($event)"><input type="radio" name="repClass" value="person" class="rep-person radio-rep"> 回复某人</label><input type = "text" readonly placeholder="点击每行选择" class = "select-person" ng-model="data2.repName">
                                    </div>
                                    <input type="text" class="form-control" placeholder="回复内容..."
                                           ng-model="reply.replies.replyDesc" id="reply">
                                    </form>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary btn-sm" ng-click="sendReply(activity,reply,data2,$event)" data-community-id = {{question.community.objId}}>回复</button>
                                    <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">取消</button>
                                </div>
                            </div>
                        </div>
                    </div>


                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>


<script>

    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
                (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                            ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }

    //    var fromDate = $('#startDate').datepicker().on('changeDate', function (ev) {
    //        //alert(ev.date.format('yyyy-MM-dd'));
    //        //$scope.startDate=ev.date.format('yyyy-MM-dd');
    //        $("#startDate").val(ev.date.format('yyyy-MM-dd'));
    ////        alert(ev.date);
    //    });

    var toDate = $('#endDate').datepicker().on('changeDate', function (ev) {
        // alert(ev.date.format('yyyy-MM-dd'));
        //$scope.endDate=ev.date.format('yyyy-MM-dd');
        $("#endDate").val(ev.date.format('yyyy-MM-dd'));
    });

    var hideContent = function(obj){
        $("#display_hide_content").css("display","block");
        $("#display_hide_content1").text(obj.innerText);
        $("#display_hide_content")[0].style.left = obj.offsetLeft + "px";
        $("#display_hide_content")[0].style.top = 60 + obj.offsetTop + "px";
    };









    $(function () {
        $('#tabs-932122 a').click(function (e) {
            e.preventDefault();//阻止a链接的跳转行为
            $(this).tab('show');//显示当前选中的链接及关联的content
        })
    })
</script>